package com.lagou.service.impl;

import com.lagou.common.Common;
import com.lagou.service.TPMonitorService;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.rpc.RpcContext;

import java.util.Random;

@Service
public class TPMonitorServiceImpl implements TPMonitorService {

    @Override
    public String sayHello(String name) {
        sleep();
        System.out.println("hello: " + name);
        return "hello:" + name;
    }

    @Override
    public String sayHi(String name) {
        sleep();
        System.out.println("hi: " + name);
        return "hi:" + name;
    }

    @Override
    public String sayHey(String name) {
        sleep();
        System.out.println("hey: " + name);
        return "hey:" + name;
    }

    private void sleep(){
        Random random = new Random();
        int i = random.nextInt(100);
        try {
            Thread.sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
